package eng;

public class Timer
{
    
    private static final double TIME_MILLI_TO_SEC = 1E-3;
    
    
    private long timeStart;
    
    public Timer(boolean start)
    {
        this.timeStart = 0L;
        if (start)
        {
            this.start();
        }
    }
    
    public final void start()
    {
        this.timeStart = System.currentTimeMillis();
    }
    
    public final double stop()
    {
        long timeStop = System.currentTimeMillis();
        long timeDiff = timeStop - this.timeStart;
        this.timeStart = 0L;
        double timeSec = Timer.TIME_MILLI_TO_SEC * timeDiff;
        return timeSec;
    }
    
    public boolean isRunning()
    {
        return (this.timeStart != 0L);
    }
    
}
